import abc
from typing import TypeVar, Generic

from algorithm.abstract_algorithm import AbstractAlgorithm
from common.source_reader import SourceReader

T = TypeVar('T')


class AbstractRunnerFrameWork(Generic[T], abc.ABC):

    @abc.abstractmethod
    def get_source(self, reader: SourceReader) -> T:
        pass

    @abc.abstractmethod
    def filter(self, data: T) -> T:
        pass

    @abc.abstractmethod
    def detect(self, data: T, algorithm: AbstractAlgorithm) -> T:
        pass

    @abc.abstractmethod
    def write(self, data: T):
        pass

    @abc.abstractmethod
    def close(self):
        pass


class AbstractFrameWorkFactory(abc.ABC):

    @abc.abstractmethod
    def create(self, params) -> AbstractRunnerFrameWork:
        pass
